//  const router = new VueRouter({
//    mode: 'history',
//    base: process.env.BASE_URL,
//    routes
//  })

import Vue from "vue"
import VueRouter from "vue-router"

// 0. 全局注册挂载插件
Vue.use(VueRouter)


// 1. 路由组件
import Home from "@/views/Home.vue"


// 2. 路由选项参数   定义路由  定义路由和组件的映射关系  path 和 component 一一映射
const routes = [
    {path:"/",redirect:'/home'},
    {path:"/home",name:"home",component:Home},
    {path:"/list",name:'list',component:()=>import("@/views/List.vue") },
    {path:"/mine",name:'mine',component:()=>import("@/views/Mine.vue") },    //路由懒加载 v-if 如果条件为假,则什么也不做
    {path:"/vuex",name:'vuex',component:()=>import("@/views/Vuex.vue") },
    {path:"*",redirect:{name:'home'}}
]



// 3.创建路由实例
const router = new VueRouter({
    routes,
    mode: 'history',
    vbase: process.env.BASE_URL
});

//路由守卫
router.beforeEach((to,from,next)=>{
    next()
})


// 4.暴露挂载
export default router